import type {Recordable} from '#/typings';

import {requestClient} from '#/api/request';

export async function login(params: Recordable<any>) {
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            resolve({
                token: 'token',
            });
        }, 1000);
    });
}

export async function logout() {
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            resolve({});
        }, 1000);
    });
}

export async function getAuthentication() {
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            resolve({
                id: 1,
                username: 'admin',
                nickname: 'admin',
                avatar: null,
                roles: ['admin'],
                codes: []
            });
        }, 1000);
    });
}

export async function refreshToken() {
    return requestClient.post('/auth/refresh', {
        withCredentials: true,
    });
}